<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>分享</title>
  <script src="https://assets.ckjr001.com/axios-v0.15.3.min.js"></script>
  <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
</head>

<body>
  <script>
    /**
     * 跳转到这个页面携带的参数
     * companyId:公司id - required
     * from:来自哪里，默认来自观看端小程序 - required
     * openId: 
     * uniondId:
     * */
    let axiosInstance;
    // https://kptest.ckjr001.com/wechatPublicPlatformAuth.html?env=1&companyId=lj7l&from=1&uri=%252Frooms%252Fpages%252Fvertical%252Findex%253FliveId%253D24939%2526socialRoomId%253D34562%2526env%253D1%2526companyId%253Dlj7l&timestamp=1741763781781
    // openId uniondId  c:公司id  backUrl:回调的地址   uri=%2Frooms%2Fpages%2Fvertical%2Findex%3FliveId%3D24939%26socialRoomId%3D34562%26env%3D1%26companyId%3Dlj7l
    function getQueryParams(url) {
      const params = {};
      if (url && url.indexOf('?') != -1) {
        const paramArr = url.slice(url.indexOf('?') + 1).split('&');
        paramArr.map(param => {
          const [key, val] = param.split('=');
          params[decodeURIComponent(key)] = decodeURIComponent(val);
        });
      }
      return params;
    }
    function serializeParams(obj = {}) {
      return Object.keys(obj)
        .map(key => {
          const value = obj[key];
          // 对键和值进行URL编码
          return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
        })
        .join('&');
    }
    function getEnvConfig() {
      let host = window.location.host;
      let env = 3; // 默认正式换将
      let apiUrl = "https://kpapiop.ckjr001.com";
      let appIds = null;
      if (host.indexOf('kptest') != -1) {
        env = 1;
      } else if (host.indexOf('formal') != -1) {
        env = 2;
      }
      if (env == 1) {
        apiUrl = 'https://kpapi-cs.ckjr001.com';
      } else if (env == 2) {
        apiUrl = 'https://formalapi.ckjr001.com'
      };
      return {
        env: env,
        apiUrl: apiUrl
      }
    }
    
    function pageOnLoad(browserEnv) {
      let queryParams = getQueryParams(window.location.href);
      
    }
   

    window.onload = () => {
      axiosInstance = axios.create({
        headers: {
          'Content-Type': 'application/json;charset=UTF-8',
        },
        timeout: 20000,
      });
      wx.miniProgram.getEnv(function (res) {
        if (res.miniprogram) {
          pageOnLoad(1);
        } else {
          pageOnLoad();
        }
      });
    };
  </script>
</body>

</html>